package com.example.configs;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

@Configuration
public class ElasticsearchConfig {

    @Value("${sitc.es.host}")
    private String host;

    @Value("${sitc.es.port}")
    private int port;

    @Primary
    @Bean
    public RestHighLevelClient transportClient() {
        return new RestHighLevelClient(
                RestClient.builder(
                        new HttpHost(host, port)));

    }
}
